<!DOCTYPE html>
<!-- v1.6.7.2 RDPROJECT-569 cx 2013-12-26 start -->
<html>
<#include "../../head.html">
    <body>
    <table class="mc">
        <tr>
            <td class="mc-l">
                <!--左侧导航---{-->
                <div id="navPanelContainer">
                    <div class="system-logo cd"></div>
                    <!--管理员信息---{-->
                    <#include "../../adminInfo.html">
                        <!--管理员信息---}-->
                        <div class="nav-wrap">
                            <#include "../left.html">
                        </div>
                </div>
                <!--左侧导航---}-->
            </td>
            <td class="mc-m">
                <div class="navToggle"></div>
            </td>
            <td class="mc-r">
                <!--顶部导航---{-->
                <#include "../../topNav.html">
                    <!--顶部导航---}-->

                    <!--面包屑导航---{-->
                    <#assign moduleName="新增积分商品">
                        <#include "../banner.html">
                            <!--面包屑导航---}-->

                            <!--工具栏--{-->
                            <div id="toolbar" class="clearfix">
                                <div class="toolbor-module search">
                                    <input type="button" class="input-button return" value="返回" onclick="location.href='creditGoodsList.html'">
                                </div>
                            </div>
                            <!--工具栏--}-->

                            <div id="main" class="clearfix">
                                <form name="form1" method="post" action="${request.getContextPath()}/admin/credit/addGoods.html"  enctype="multipart/form-data" >
                                    <div class="valBox w750">
                                        <div class="top">
                                            <strong>新增积分商品</strong>
                                        </div>
                                        <div class="val clearfix">
                                            <ul>
                                                <li>
                                                    <div class="title">商品名称：</div>
                                                    <div class="v">
                                                        <input type="text" id="name" name="name"/>
                                                    </div>
                                                </li>
                                                <li>
                                                	<div class="title">所需积分：</div>
                                                	<div class="v">
                                                		<input type="text" id="credit_value" name="credit_value" onkeyup="this.value=this.value.replace(/\D/g,'')">
                                                	</div>
                                                </li>
                                                 <li>
                                                	<div class="title">商品数量：</div>
                                                	<div class="v">
                                                		<input type="text" id="store" name="store" onkeyup="this.value=this.value.replace(/\D/g,'')">
                                                	</div>
                                                </li>
                                                <li>
                                                    <div class="title">商品类别：</div>
                                                    <div class="v">
                                                    	<select id="category_id">
                                                    		<option value=""></option>
                                                    		<#list cateList as item>
                                                    		<option value="${item.id}">${item.name}</option>
                                                    		</#list>
                                                    	</select>
                                                    </div>
                                                    </li>
                                                <li>
                                                    <div class="title">子类别：</div>
                                                    <div class="v">
                                                    	<select name="category_id" id="child_category_id">
                                                    	</select>
                                                    </div>
                                                </li>
                                                 <li>
                                                	<div class="title">商城售价：</div>
                                                	<div class="v">
                                                		<input type="text" name="cost" onkeyup="value=value.replace(/[^0-9.]/g,'')" >
                                                	</div>
                                                </li>
                                                 <li>
                                                	<div class="title">市场价：</div>
                                                	<div class="v">
                                                		<input type="text" name="market_price" onkeyup="value=value.replace(/[^0-9.]/g,'')">
                                                	</div>
                                                </li>
                                                 <li>
                                                    <div class="title">上架时间：</div>
                                                    <div class="v">
                                                    	<input id="shelves_time" class="_search-value js-datetime" name="shelves_time" readonly="readonly"/>
                                                    </div>
                                                </li>
                                                <li>
                                                	<div class="title">商品图片：</div>
                                                	<div class="v" style="float: left;">
                                                		<input type="file" id="pic_url" name="pic_url">
                                                		
                                                	</div>
                                                	<div id="imgShow" style="float: left;">
                                                	
                                                	</div>
                                                	<a onclick="javascript:delAllPic();">删除图片</a>
                                                	
                                                </li>
                                              <!--     <li>
                                                    <div class="title">商品详情：</div>
                                                    <div class="v">
                                                    	<textarea rows="3" cols="100" name="description" ></textarea>
                                                    </div>
                                                </li>
                                               -->
                                                <br/>
                                                <li>
                                                    <div class="title">商品属性信息：</div>
                                                    <div class="v">
                                                        <textarea rows="3" cols="100" name="attribute" ></textarea>
                                                    </div>
                                                </li>
                                                <br/>
                                                <li>
                                                    <div class="title">备注：</div>
                                                    <div class="v">
                                                    	<textarea rows="5" cols="100" name="remarks" ></textarea>
                                                    </div>
                                                </li>
                                            </ul>
                                            <div>
                                             	<textarea id="fileValue" name="fileValue" style="display: none;"></textarea>
                                             </div>
                                            <div class="other">
                                                <input type="hidden"  name="actionType" value="addGoods" />
                                                <input type="button"  value="新增" onclick="addGoods();" class="input-button confirm"/>
                                            </div>
                                        </div>
                                    </div>

                                </form>

                            </div>
            </td>
        </tr>
        <tr>
            <!--尾部--{-->
            <td colspan="3" class="mc-b"><#include "../../foot.html"></td>
            <!--尾部--}-->
        </tr>
    </table>
<script type="text/javascript" src="${request.getContextPath()}/themes/admin/js/uploadify/uploadify.css"></script>
<script type="text/javascript" src="${request.getContextPath()}/themes/admin/js/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	 $('#pic_url').uploadify({
		  'fileObjName' : 'pic_url',
	      'buttonText':'点击添加',
	      'fileTypeDesc':'Image Files',
	      'fileTypeExts':'*.gif; *.jpg; *.png',
	      'fileSizeLimit':'1048276',
	      'swf':'${request.getContextPath()}/themes/admin/js/uploadify/uploadify.swf',
	      'uploader':'${request.getContextPath()}/admin/credit/uploadImg.html;jsessionid=${sessionId}',
	      'onUploadSuccess':function(file,data, response) {
	    	  if(data!=null){
	          	$('#imgShow').append("<img src='${request.getContextPath()}/data/goodsImg/"+data+"' width='50px' height='50px' />");
	          	$('#fileValue').val($('#fileValue').val()+","+data);
	    	  }
	        }
		 });
	
}); 
function delAllPic(){
	$('#imgShow').html('');
	$('#fileValue').val('');
}
     $('#category_id').change(function(){
    	 $('#child_category_id').html("");
    	 $.ajax({
    		 dataType:'json', 
    		 url:'${webroot}/credit/childCreditCatagory.html?id='+$(this).val(),
    		 success:function(data){
    			 if(data!=null){
    				 var str=data.goryList;
    				 for(var i=0;i<str.length;i++){
    					 $('#child_category_id').append("<option value="+str[i].category_id+">"+str[i].name+"</option>")
    				 }
    			 }
    		 }
    		 
    	 });
    	 
     });
   
   		function addGoods(){
   			if($('#name').val()==''){
   				alert("请输入商品名称！");
   				return false;
   			}
   			if($('#credit_value').val()==''){
   				alert("请输入需要兑换的积分值！")
   				return false;
   			}
   			if($('#store').val()==''){
   				alert("请输入商品数量！");
   				return false;
   			}
   			if($('#category_id').val()==''||$('#child_category_id').val()==''){
   				alert("请输入商品类别！");
   				return false;
   			}
   			if($('#fileValue').val==''){
   				alert("请选择上传的图片！");
   				return false;
   			}
   			if($('#shelves_time').val()==''){
   				alert("请选择上架时间！");
   				return false;
   			}
   			if($('#description').val()==''){
   				alert("请描述商品详情！");
   				return false;
   			}
   			document.forms[0].submit();
   		}
   
   </script> 
<div class="msgClass"> ${rsmsg!""}</div>
    </body>
</html>
<#include "../../jsPage.html">
<!-- v1.6.7.2 RDPROJECT-569 cx 2013-12-26 start -->
